﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" EnableViewState="false"
Inherits="System.Web.Mvc.ViewPage<Gman.WebApp.Models.ProveedorModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


    <script src="../../Scripts/Binding/Proveedor.js" type="text/javascript"></script>
    <script type="text/javascript">
        var guid = "<%= Model.ID.ToString()%>";

        var action = "<%= Model.Action.ToString()%>";


        $(document).ready(function() {
            SetupControls();
            SetupActions();
            SetupDropDowns();

            $("#AddPersonal").click(function() {
                LoadAddOrEditPersonal(null);
            });


            $("#Ubigeo_CodDpto").change(function() {

                var url = '<%= Url.Content("~/") %>' + "Proveedor/Prvncias_SelectedDprt";


                var ddlsource = "#Ubigeo_CodDpto";
                var ddltarget = "#Ubigeo_CodProv";

                $.getJSON(url, { Sel_Dpto: $(ddlsource).val() }, function(data) {
                    $(ddltarget).empty();
                    $.each(data, function(index, optionData) {

                        $(ddltarget).append("<option  value='" + optionData.CodProv + "'>" + optionData.DescUbigeo + "</option>");

                    });
                });


            });




            $("#Ubigeo_CodProv").change(function() {

                var url = '<%= Url.Content("~/") %>' + "Proveedor/Dictritos_SelectedProv";
                var ddlcboCodDpto = "#Ubigeo_CodDpto";
                var ddlcboCodProv = "#Ubigeo_CodProv";
                var ddlcboCodDist = "#Ubigeo_CodDist";

                $.getJSON(url, { Sel_Prov: $(ddlcboCodProv).val(), Sel_Dpto: $(ddlcboCodDpto).val() }, function(data) {

                    $(ddlcboCodDist).empty();
                    $.each(data, function(index, optionData) {

                        $(ddlcboCodDist).append("<option  value='" + optionData.CodDist + "'>" + optionData.DescUbigeo + "</option>");

                    });

                });


            });

            var x = $("#dialog-form");

            $("#dialog-form").dialog({
                autoOpen: false,
                height: 300,
                width: 850,
                modal: true

            });


            $("#btnBuscar")
      .click(function(event) {
          $("#dialog-form").dialog("open");
          event.preventDefault();
      });



            $("#Div1").dialog({
                autoOpen: false,
                height: 250,
                width: 850,
                modal: true

            });

            $("#Button2")
      .click(function(event) {
          $("#Div1").dialog("open");
          event.preventDefault();


      });




        });


        $(function() {

            $(".newsitem")
      .click(function(event) {

          var x = $("#dialog-form");

          x.effect("explode", {}, 450, callback(x));
          x.dialog("close");


      });

            function callback(x) {
                setTimeout(function() {
                    x.removeAttr("style").hide().fadeIn();
                }, 1000);
            };



            $(".newper")
      .click(function(event) {
          $("#Div1").dialog("open");
          event.preventDefault();
      });




            $("#Button3").click(function(event) {


                BuscarProveedor();
            });


            //prueba  con metdo
            function BuscarProveedor() {

                var cad1 = $("#proveedor_RucProvP").val();
                var url = '<%= Url.Content("~/") %>' + "Proveedor/BuscarProveedor";
                $.getJSON(url, { cad: cad1 }, function(data) {
                    //                       
                    $("#GridLista").find("tr:gt(0)").remove();
                    $.each(data, function(index, optionData) {
                        var id = optionData.IDProveedor;
                        var cad = "<a  class='newsitem' href='/proveedor/Select/" + id + "'>Seleccionar</a>";

                        $("#GridLista").append("<tr>" +
                           "<td>" + cad + "</td>" +
                           "<td>" + optionData.RucProv + "</td>" +
                           "<td>" + optionData.RazonSProv + "</td>" +
                           "<td>" + optionData.NroCeluProvee + "</td>" +
                           "<td>" + optionData.NroTelfProvee + "</td>" +
                           "<td>" + optionData.DirecProv + "</td>" +
                         "</tr>");

                    });
                });



            }


        });
     
    </script>
    <div style="margin-top: 5px;">
        <div class="DataTop">
            <div class="DataTopLeft">
            </div>
            <div class="DataTopRight">
            </div>
        </div>
        <div class="DataContent">
            <div class="DataContentRight" style="height: 50px;">
                <b>Proveedor </b>
                <% Html.RenderPartial("ToolBar", Model.ToolBar); %>
            </div>
        </div>
        <div class="DataBottom">
            <div class="DataBottomLeft">
            </div>
            <div class="DataBottomRight">
            </div>
        </div>
    </div>
    <div class="DataContent">
        <div class="DataContentRight">
            <div class="DataTable">
                <% using (Html.BeginForm())
                   {%>
                <div>
                    <%-- <h2>Proveedor</h2>--%>
                    <fieldset>
                       <%-- <legend>Proveedor</legend>--%>
                        <%-- <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
            <ContentTemplate>--%>
                        <table align="left">
                            <tr>
                                <td style="width: 150px;" class="editor-label">
                                    Ruc Proveedor
                                </td>
                                <td style="width: 150px">
                                    <div>
                                        <%= Html.TextBoxFor(model => model.proveedor.RucProv, new { propertyname = "proveedor.RucProv", ID = "proveedor_RucProv" })%>
                                    </div>
                                </td>
                                <td align="left">
                                    <%--<asp:ImageButton ID="btnFiltrar" runat="server" 
                            ImageUrl="~/_Images/Search-icon-16.png"
                             CssClass="botonSearch" />src="~/_Images/Search-icon-16.png"
                             style="background-image:url(/_Images/Search-icon-16.png);
                            width:20px--%>
                                    <%--<button type="submit" id="btnbuscar" value="B" title="B"/>--%>
                                    <%--<button id="create-user">
                                        B</button>--%>
                                    <img id="btnBuscar" src="../../_Images/Search-icon-16.png" alt="Buscar sede" style="cursor: pointer;" />
                                    <%--<input type="submit" id="Button1" value="C" />--%>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 150px;">
                                    Razon social
                                </td>
                                <td style="width: 450px">
                                    <div>
                                        <%= Html.TextBoxFor(model => model.proveedor.RazonSProv, new { propertyname = "proveedor.RazonSProv", ID = "proveedor_RazonSProv" })%>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 150px;">
                                    Dirección
                                </td>
                                <td style="width: 150px">
                                    <%-- <div style="width:100%" >--%>
                                    <%= Html.TextBoxFor(model => model.proveedor.DirecProv, new { propertyname = "proveedor.DirecProv", ID = "proveedor_DirecProv" })%>
                                    <%-- </div>--%>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 150px;">
                                    Departamento
                                </td>
                                <td style="width: 150px">
                                    <div>
                                        <%--  <%= Html.DropDownListFor(model => model.proveedor.CodUbigeo, Model.Departamento)%>--%>
                                        <%= Html.DropDownListFor(model => model.Ubigeo.CodDpto, Model.Departamento,
                                       new { style = "width: 60%;font-size: xx-small;", propertyname = "Ubigeo.CodDpto", ID = "Ubigeo_CodDpto" })%>
                                    </div>
                                </td>
                                <td style="width: 150px;">
                                    Provincia
                                </td>
                                <td style="width: 150px">
                                    <div>
                                        <%--<%= Html.TextBoxFor(model => model.proveedor.CodUbigeo)%>--%>
                                        <%= Html.DropDownListFor(model => model.Ubigeo.CodProv, Model.Provincia,
                                            new { style = "width: 100%;;font-size: xx-small;", propertyname = "Ubigeo.CodProv",ID = "Ubigeo_CodProv" })%>
                                    </div>
                                </td>
                                <td style="width: 150px;">
                                    Distrito
                                </td>
                                <td style="width: 150px">
                                    <div>
                                        <%--<%= Html.TextBoxFor(model => model.proveedor.CodUbigeo)%>--%>
                                          <%= Html.DropDownListFor(model => model.Ubigeo.CodDist, Model.Distrito, new { style = "width: 100%;;font-size: xx-small;", propertyname = "Ubigeo.CodDist", ID = "Ubigeo_CodDist" })%>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 150px;">
                                    Telefono
                                </td>
                                <td style="width: 150px">
                                    <div>
                                        <%= Html.TextBoxFor(model => model.proveedor.NroTelfProvee, new { propertyname = "proveedor.NroTelfProvee", ID = "proveedor_NroTelfProvee" })%>
                                    </div>
                                </td>
                                <td style="width: 150px;">
                                    Anexo
                                </td>
                                <td style="width: 150px">
                                    <div>
                                        <%= Html.TextBoxFor(model => model.proveedor.AnexProv, new { propertyname = "proveedor.AnexProv", ID = "proveedor_AnexProv" })%>
                                    </div>
                                </td>
                                <td style="width: 150px;">
                                    Celular
                                </td>
                                <td style="width: 150px">
                                    <div>
                                        <%= Html.TextBoxFor(model => model.proveedor.NroCeluProvee, new { propertyname = "proveedor.NroCeluProvee", ID = "proveedor_NroCeluProvee" })%>
                                    </div>
                                </td>
                                <td style="width: 150px;">
                                    Fax
                                </td>
                                <td style="width: 150px">
                                    <div>
                                        <%= Html.TextBoxFor(model => model.proveedor.FaxProv, new { propertyname = "proveedor.FaxProv", ID = "proveedor_FaxProv" })%>
                                    </div>
                                </td>
                            </tr>
                        </table>
                        <%-- 
             </ContentTemplate>
            </asp:UpdatePanel>--%>
                    </fieldset>
                </div>
                <% } %>
            </div>
        </div>
    </div>
    
    
   <%-- <div class="DataContent">
        <div class="DataContentRight">--%>
         <%--   <div class="DataTable">
                <fieldset>
                    <legend>Personal Proveedor</legend>
                    <table align="left">
                        <tr>
                            <td style="width: 150px;">
                                Nro Documento
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtnroDoc") %>
                                </div>
                            </td>
                            <td style="width: 150px;">
                                Nombres
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtNombre") %>
                                </div>
                            </td>
                            <td style="width: 150px;">
                                Cargo
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtCargo") %>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 150px;">
                                Tipo
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtTipo") %>
                                </div>
                            </td>
                            <td style="width: 150px;">
                                Email
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtEmail") %>
                                </div>
                            </td>
                            <td style="width: 150px;">
                                Telefono
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtTelefono") %>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 150px;">
                                Estado Personal
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtStado") %>
                                </div>
                            </td>
                            <td style="width: 150px;">
                                Celular
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtCelular") %>
                                </div>
                            </td>
                            <td style="width: 150px;">
                                Rpm
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtRpm") %>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 150px;">
                                Nextel
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtNextel") %>
                                </div>
                            </td>
                            <td style="width: 150px;">
                                Rpc
                            </td>
                            <td style="width: 150px">
                                <div>
                                    <%= Html.TextBox("txtRpc") %>
                                </div>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </div>--%>
        
       <%-- </div>
    </div>--%>
   
   
   
    <div class="DataContent">
        <div class="DataContentRight">
            <%--<div>
                <table class="GridLista" style="width: 100%">
                    <tr class="HeaderStyle">
                        <th>
                        </th>
                        <th>
                            Nro DNI
                        </th>
                        <th>
                            Nombre y Apellidos
                        </th>
                        <th>
                            Cargo
                        </th>
                        <th>
                            Tipo
                        </th>
                        <th>
                            Email
                        </th>
                        <th>
                            Telefono
                        </th>
                    </tr>
                </table>
            </div>--%>
            
            <br />
            <b>Personal de proveedor </b> 
            <input id="AddPersonal" type="submit" value="Adicionar" style="float:right;"/> 
       <div id="ListaPersonalDiv">
       <%  Html.RenderPartial("ListaPersonal",Model); %> 
        </div>
        </div>
    </div>
    
    
    
    <div id="dialog-form" title="Busqueda de Proveedor">
      


   <div class="DataContent" style ="width:100%">
    
        <div class="DataContentRight">
        <div class="DataTable">
     <table align="left">
                <tr>
                    <td style="width: 150px;" class="editor-label">
                        Ruc Proveedor
                    </td>
                    <td style="width: 150px">
                        <div>
                            <%= Html.TextBoxFor(model => model.proveedor.RucProv, new { id = "proveedor_RucProvP" })%>
                        </div>
                    </td>
                    <td><button id="Button3" >B</button>
                    </td>

                    </tr>
                    
    
    </table>
     </div>
     </div>
     </div>
    
    <div class="DataContent">
        <div class="DataContentRight">
            <div class="DataTable">
                <table class="GridLista" style="width: 100%" id="GridLista">
                    <tr class="HeaderStyle">
                           
                         <th>
                        </th>
                        <th>
                            Ruc
                        </th>
                        <th>
                            RazonSProv
                        </th>
                        <th>
                            NroCeluProvee
                        </th>
                        <th>
                            NroTelfProvee
                        </th>
                        <th>
                            Direccion
                        </th>
                    </tr>

                     <% foreach (var item in Model.proveedorList) { %>
    
        <tr class="ItemStyle">
            <td>
                <%--<%= Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) %> |
                <%= Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ })%> |
                <%= Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })%>--%>
                <%= Html.ActionLink("Seleccionar", "Select" ,new { id = item.IDProveedor }, new { @class = "newsitem" })%> 
            </td>
            <td>
                <%= Html.Encode(item.RucProv) %>
            </td>
            <td>
                <%= Html.Encode(item.RazonSProv) %>
            </td>
            <td>
                <%= Html.Encode(item.NroCeluProvee)%>
            </td>
            <td>
                <%= Html.Encode(item.NroTelfProvee)%>
            </td>
            <td>
                <%= Html.Encode(item.DirecProv)%>
            </td>
        </tr>
    
    <% } %>

                </table>
            </div>
        </div>
    </div>

    </div>

    <div id="PersonalPopupDiv">
</div>
</asp:Content>
